package ctrler;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

import vues.VueConnexion;
import vues.VueInscrire;

public class CtrlerConnexion extends AbstractAction{

	private static final long serialVersionUID = 6272979649731009730L;
	
	private VueConnexion vueCo;
	
	public CtrlerConnexion(VueConnexion vueCo, String texte){
		super(texte);
		this.vueCo = vueCo;
	}
	
	public void actionPerformed(ActionEvent e) { 
		JButton source = (JButton)e.getSource();
		//if(e.getSource().equals("btnConnexion")){
		if(source.getText().equals("Connecter")){
			String log = vueCo.getjtLogin();
			String mdp = vueCo.getjtMdp();
			System.out.println("Clic Connecter \nLOGIN :" + log + "\nPASSWORD :"+ mdp);
		} else if(source.getText().equals("Annuler")){
			System.out.println("Clic Annuler");
			System.exit(0);
		} else if(source.getText().equals("S'inscrire")){
			SwingUtilities.invokeLater(new Runnable(){
				public void run(){
					VueInscrire vueIns = new VueInscrire();
					vueIns.setVisible(true);
				}
			});
			vueCo.setVisible(false);
			System.out.println("Clic S'inscrire");	
		}
	} 

}

